<template>
	<div class="page-content">
		<div class="page-title">
			请在身份证读卡区刷身份证
			<div style="float: right;"><Timer title="刷身份证"></Timer></div>
		</div>
		
		<div style="height: 695px; background-color: #f8f9fb; "  >
			 
			<div style="color: #82899f; font-family: '微软雅黑';font-size: 30px; padding:40px;">身份信息识别后，请及时取走您的身份证</div>
		 
			 <div class="flex">
				 <div style="flex:1"></div>
				 <img src="res/input/machine-idcard.png" />
				  <div style="flex:1" class="box-center">
					  <img src="res/input/arrow-idcard.png" />
				  </div>
			 </div> 
		</div>
		
		<div style="height: 129px;" >
			<a class="btn-big" @click="clickChooseOther"  >
				如果没有身份证，请点此选择其他证件
			</a>
		</div>
	</div>
	
</template>

<script>
	//TODO: 10秒超时自动退出
	export default{
		data(){
			return {
				delayRunId:0,
				url:this.$route.path,
			}
		},
		
		created(){
			this.send({name:'ReadIdCard',remark:'识别身份证信息'});
			this.listen((data)=>{
				if(data.result == 'error'){
					this.toast(data.message);
					this.delayRunId = this.delayRun(()=>{
						this.send({name:'ReadIdCard',remark:'识别身份证信息', route:this.url});
					}, 3000) 
				} else if(data.result == 'success'){
					sessionStorage.setItem('idcard', JSON.stringify(data.idcard) );
					this.$router.push('/check/input/certificate-confirm');
				}
				console.log('读卡信息: ' + JSON.stringify(data))
			})
		},
		
		beforeDestroy(){
			if(this.delayRunId != 0){
				this.cancleRun(this.delayRunId);
			}
		},
		
		methods:{
			clickChooseOther(){
				this.sendLog('用户无身份证，选择其他证件类型。');
				this.$router.push('/check/input/certificate-type')
			}
		}
		
	}
</script>

<style>
</style>
